<div class="judul"><?php echo anchor("/info_rekap_keuangan_bulanan/",$title);?></div>
<?php
  $uri_segment = $this->uri->segment(3);
  if($uri_segment != ""){
      $params = parsing_param2($uri_segment);
      $bln1 = $params['bln1'];
      $bln2 = $params['bln2'];
      $thawal = $params['thawal'];
      $thakhir = $params['thakhir'];
      $jenis = $params['jenis'];
      $selisih = $thakhir-$thawal;
  }else{
      $bln1 = "";
      $bln2 = "";
      $jenis = '';
      $thawal = date('Y');
      $thakhir = date('Y');
      $selisih = 0;
  }
?>
<script type="text/javascript">
    $(document).ready(function(){
        <?php
          if($jenis == 'tahunan'){
        ?>
           $('#tahunan').show();
           $('#bulanan').hide();
        <?php        
          }else if($jenis == 'bulanan'){
        ?>
           $('#bulanan').show();     
           $('#tahunan').hide();     
        <?php        
          }else{
        ?>
           $('#bulanan').show();     
           $('#tahunan').hide();     
        <?php        
          }
        ?>
        $('#periode').change(function(){
            if($('#periode').val() == 'Bulanan'){
                $('#bulanan').show();
                $('#tahunan').hide();
            }else if($('#periode').val() == 'Tahunan'){
                $('#tahunan').show();
                $('#bulanan').hide();
            }
        })
    })
</script>
<div class="data-input">
  <fieldset>
      <legend>Parameter Pencarian</legend>
      <label>Periode</label>
      <select id="periode">
          <option value="Bulanan" <?php if($jenis == 'bulanan') echo "selected";?>>Bulanan</option>
          <option value="Tahunan" <?php if($jenis == 'tahunan') echo "selected";?>>Tahunan</option>
      </select>
      <div id="bulanan">
          <fieldset class="field-group">
              <?php
                echo form_open("info_rekap_keuangan_bulanan/search","name='form'");
              ?>  
              <label>Bulanan</label>
                <?php searchBulanan($bln1, $bln2, $thawal, $thakhir);?>
          </fieldset>
          <fieldset class="input-process">
          <?php  
              echo form_hidden("Apply",TRUE);
              echo form_hidden("url", $searchLink);
              echo form_hidden("jenis", "bulanan");
              echo form_submit('cari','Cari',"class='button' style='margin-right:2px'");
              echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/info_rekap_keuangan_bulanan/'".'');
              echo form_close();
            ?>
          </fieldset> 
      </div>    
      <div id="tahunan">
          <fieldset class="field-group">
              <?php
                echo form_open("info_rekap_keuangan_bulanan/search","name='form'");
              ?>  
              <label>Tahunan</label>
              <?php searchTahunan($thawal, $thakhir);?>
              <fieldset class="input-process">
              <?php  
                  echo form_hidden("Apply",TRUE);
                  echo form_hidden("url", $searchLink);
                  echo form_hidden("jenis", "tahunan");
                  echo form_submit('cari','Cari',"class='button' style='margin-right:2px'");
                  echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/info_rekap_keuangan_bulanan/'".'');
                  echo form_close();
                ?>
             </fieldset>     
          </fieldset>  
      </div>    
 </fieldset> 
</div>    
<fieldset>
<?php
  if($params['Apply'] == TRUE){
?>
<center>
    <h1>Informasi Grafik Saldo Per Periode</h1>
    <h2>Periode <?php echo $bln1.' '.$thawal?> s.d <?php echo $bln2.' '.$thakhir?></h2>
<?php
  if(file_exists($graph)){
?>
  <img src="<?php echo base_url().$graph;?>" />
</center>  
<?php
  }
  if($jenis == 'bulanan'){
?>   
  <div class="data-list">
    <table class="tabel">
    <?php
         $no = 1;
         $selisih = $selisih + 1;
         for($i = $thawal;$i <= $thakhir;$i++){
            if ($no == 1) {
                if ($thawal == $thakhir)
                    $cols = blnAngka($bln2) - blnAngka($bln1) + 1;
                else
                    $cols = 12 - blnAngka($bln1) + 1;
            }
            else if ($no == $selisih) {
                $cols = blnAngka($bln2);
            } else {
                $cols = 12;
            }
            
            echo "<th colspan='$cols'>$i</th>";
            $no += 1;    

         }
         echo "</tr><tr>";
         $selisih = $thakhir - $thawal;
         for ($i = blnAngka($bln1); $i <= blnAngka($bln2) + ($selisih * 12); $i++) {
            echo "<th width='65px'>" . bln($i, $thawal, $thakhir). "</th>";
         }
         echo "</tr><tr>";
         foreach ($listRekapKeuanganBulanan['master'] as $key => $row){
             echo "<td align='right' class='no-wrap'>Rp. ".rupiah($row[0]['jumlah'])."</td>";
         }
         echo "</tr>";  
    ?>    
    </table>
  </div>
<?php
  }else if($params['jenis'] == 'tahunan'){
      $selisih = ($params['thakhir'] - $params['thawal']);
        
      echo "<div class='data-list'>
      <table class='tabel'>";
      echo "<tr>";
      $thn = $params['thawal'];
      for($i = 0; $i <= $selisih; $i++){
          echo "<th>$thn</th>";
          $thn++;
      }
      echo "</tr>";
      echo "<tr>";
      foreach ($listRekapKeuanganTahunan['master'] as $rows){
          echo "<td align='right' class='no-wrap'>Rp. ".rupiah($rows[jumlah])."</td>";
      }
      echo "</tr>";
      echo "</table></div>";
  }
  }else{
      echo "<span class='tips'>Silahkan menggunakan opsi pencarian di atas</span>";
  }
?>
</fieldset>